#include "HTMLParser.h"
#include "ThreadFunctionDatabase.h"


HTMLParser ThreadFunctionDatabase::h1;
HTMLParser ThreadFunctionDatabase::h2;
uint ThreadFunctionDatabase::contIter;

void * ThreadFunctionDatabase::parseOdds (void * textos) {
	string * texto = (string *)(textos);
	
	for(uint ii=1; ii < contIter; ii+=2) {
		if (ii % 473 == 17) 
			cout << "j: " << ii << endl;	
		texto[ii] = h1.extractText(texto[ii]);
	}
	h1.coutStatistics("htmlEstatisticaOdds.txt");
	pthread_exit(NULL);
}

void * ThreadFunctionDatabase::parseEvens (void * textos) {
	string * texto = (string *)(textos);
	
	for(uint ii=0; ii < contIter; ii+=2) {
		if (ii % 473 == 17) 
			cout << "j: " << ii << endl;	
		texto[ii] = h2.extractText(texto[ii]);
	}
	h2.coutStatistics("htmlEstatisticaEvens.txt");
	pthread_exit(NULL);
}

void ThreadFunctionDatabase::setContIter(uint value) {
	contIter = value;
}
